import requests
from lxml import etree
import csv
import pandas
def get_html(url,time=30):
    try:
        r = requests.get(url=url,timeout=time)
        r.encoding = r.apparent_encoding
        r.raise_for_status()
        return r.text
def parser(html):
    doc = ctree.html(html)
    title = doc.xpath('//*[@id="rankWrap"]/div[2]/ul/li[1]')
    href = doc.xpath('//*[@id="rankWrap"]/div[2]/ul/li[1]/a')
    out_dict = {"歌名":title,"地址":href}
    return out_dict
def save_dict2csv(item,path):
    df = pandas.DataFrame(item)
    df.to_csv(path)
if __name__ == '__main__':
    url = "http"